package com.imy.luascript.app.ui.precode;

import android.app.Activity;
import android.view.View;
import android.widget.TextView;

import com.imy.common.base.adapter.BaseDelegate;
import com.imy.common.base.adapter.BaseRecyclerViewHolder;
import com.imy.luascript.R;

import java.io.File;

import butterknife.BindView;

/**
 * create by Imy
 */
public class PreviewCodeDelegate extends BaseDelegate<File, PreviewCodeDelegate.Holder> {



  public PreviewCodeDelegate(Activity activity) {
    super(activity);
  }

  @Override
  protected boolean isShow(File s) {
    return true;
  }

  @Override
  protected int getLayoutID() {
    return R.layout.list_item_code_file;
  }

  @Override
  protected Holder getHolder(View view) {
    return new Holder(view);
  }

  @Override
  protected void bindView(Holder holder, int position, File s) {
      //默认为main
    holder.mFileNameTv.setText(s.getName());
    if (currentFile.getName().equals(s.getName())){
      holder.mIndicatorView.setVisibility(View.VISIBLE);
    }else {
      holder.mIndicatorView.setVisibility(View.INVISIBLE);
    }
  }

  public void setCurrentFile(File file){
    currentFile=file;
  }
  private File currentFile;

  public File getCurrentFile() {
    return currentFile;
  }

  public static class Holder extends BaseRecyclerViewHolder {
    @BindView(R.id.file_name_tv) TextView mFileNameTv;
    @BindView(R.id.indicator_view) View mIndicatorView;
    public Holder(View itemView) {
      super(itemView);
    }
  }
}
